package com.etone.H2;

import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Types;

import org.h2.tools.SimpleResultSet;


public class DataBaseOperator {

	
	public static void createTable(ResultSet rs){
		ResultSetMetaData rsmd = null;
		try {
			rsmd = rs.getMetaData();
			int count = rsmd.getColumnCount();
			StringBuilder createSql = new StringBuilder();
			createSql.append("create table temp(");
			
			
			for(int i=1;i<=count;i++){
				
				System.out.print("," + rsmd.getColumnName(i));
				System.out.print("," + rsmd.getPrecision(i));
				System.out.print("," + rsmd.getScale(i));
				System.out.print("," + rsmd.getColumnType(i));
				System.out.print("," + rsmd.getColumnTypeName(i));
				System.out.print("," + rsmd.isNullable(i));
				System.out.println();

				
//				nameList.put(rsmd.getColumnName(i));
			}
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
	public static void main(String[] args) {
		SimpleResultSet rs = new SimpleResultSet();
		rs.addColumn("id", Types.BIGINT, 1, 3);
		rs.addColumn("name", Types.VARCHAR, 222, 3);
//		DataBaseOperator.createTable(Export2Csv.getResult());
	}
}
